﻿Public Class SmallLiteralLabel
    'Implements ICtagControl.TenKeyLabel.IfTenkeyLabel

    Private iRatio As Integer = 80

    Public Event InputCompleted(ByVal Sender As Object)

    Public ReadOnly Property IsEditing As Boolean 'Implements TenKeyLabel.IfTenkeyLabel.IsEditing
        Get
            Return lblValue.IsEditing
        End Get
    End Property

    Public ReadOnly Property IsChanged As Boolean 'Implements TenKeyLabel.IfTenkeyLabel.IsChanged
        Get
            Return lblValue.IsChanged
        End Get
    End Property

    Public Overrides Property BackColor As Color
        Get
            Return lblValue.BackColor
        End Get
        Set(ByVal value As Color)
            If Not lblValue.IsEditing Then
                lblLiteral.BackColor = value
                lblValue.BackColor = value
            End If

        End Set
    End Property

    ''' <summary>
    ''' 提示文字の幅の比率
    ''' </summary>
    ''' <value>0-100の数字</value>
    ''' <remarks></remarks>
    Public WriteOnly Property Ratio As Integer
        Set(ByVal value As Integer)
            If value < 0 Then
                iRatio = 0
            ElseIf value > 100 Then
                iRatio = 100
            Else
                iRatio = value
            End If
        End Set
    End Property

    Public Property Literal As String
        Get
            Literal = lblLiteral.Text
        End Get
        Set(ByVal value As String)
            lblLiteral.Text = value
        End Set
    End Property

    Public Overrides Property Text As String
        Get
            Text = lblValue.Text
        End Get
        Set(ByVal value As String)
            lblValue.Text = value
        End Set
    End Property

    Public Property InputLabel As Label
        Get
            Return lblValue
        End Get
        Set(ByVal value As Label)

        End Set
    End Property

    Public Sub ClearText() ' Implements ICtagControl.TenKeyLabel.IfTenkeyLabel.ClearText
        lblValue.ClearText()
    End Sub

    Public Sub EndEdit() ' Implements TenKeyLabel.IfTenkeyLabel.EndEdit
        lblValue.EndEdit()
    End Sub

    Private Sub lblValue_BackColorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lblValue.BackColorChanged
        lblLiteral.BackColor = lblValue.BackColor
    End Sub

    Private Sub lblValue_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lblValue.Click
        Me.OnClick(e)
    End Sub

    Protected Sub OnEndEdit() Handles lblValue.InputCompleted
        RaiseEvent InputCompleted(Me)
    End Sub

    Private Sub LiteralLabel_FontChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.FontChanged
        lblLiteral.Font = Me.Font
        lblValue.Font = Me.Font
    End Sub

    Private Sub LiteralLabel_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
        lblLiteral.Height = Me.Height
        lblValue.Height = Me.Height

        lblValue.Width = Me.Width * iRatio / 100
        lblLiteral.Width = Me.Width - lblValue.Width

        lblLiteral.Left = 0
        lblValue.Left = lblLiteral.Right
    End Sub
End Class
